<h1>Editing report</h1>

<% form_for @report do |f| %>
  <%= f.error_messages %>
  <label>Label:</label>
  <%= f.text_field :label %><br />
  <label>Description:</label>
  <%= f.text_field :description %><br />
  <label>Date estimée:</label>
  <%= f.text_field :estimated_date %><br />
  <label>Select priority:</label>
  <%= f.text_field :select_priority %><br />
  <%= submit_tag %>
<% end %>

<h2>Tag(s)</h2>

<% form_tag '/reports/tag',:method=>:post do %>
  <%= hidden_field_tag :report_id, @report.id %>
  <label>Add:</label>
  <%= select_tag "reporttag_id", options_from_collection_for_select(Reporttag.all, :id, :name) %>
  <%= submit_tag 'Add' %>
<% end %>

<table>
  <tr>
    <th>Name</th>
  </tr>
  <% @report.reporttags.each { |reporttag| %>
  <tr>
    <td>
      <a href="<%= url_for(:controller=>"reporttags", :action=>"show",:id=>reporttag.id) %>">
        <%=h reporttag.name %>
      </a>
    </td>
    <td>
      <% form_tag '/reports/untag',:method=>:post do %>
      <%= hidden_field_tag :report_id, @report.id %>
      <%= hidden_field_tag :reporttag_id, reporttag.id %>
      <%= submit_tag 'remove' %>
    <% end %>
    </td>
  </tr>
  <%}%>
</table>

<hr />
<%= link_to 'Show', @report %> |
<%= link_to 'Back', reports_path %>
